import Loader from './loader.js';
import Util from './util.js';
import Formatter from './formatter.js';
import Constant from './constant.js';

class Framework {
  constructor(options) {

  }

  /**
   * @returns {Loader}
   */
  get Loader() {
    return Loader;
  }

  /**
   * @returns {Formatter}
   */
  get formatter() {
    return Formatter;
  }

  /**
   * @returns {Util}
   */
  get util() {
    return Util;
  }

  get constant() {
    return Constant;
  }

  get redirect() {
    return {
      home: () => {
        window.vue.$router.push('/');
      },
      login: () => {
        const enableSso =
          process.env.VUE_APP_ENABLE_SSO === true ||
          process.env.VUE_APP_ENABLE_SSO === "true";
        if (enableSso) {
          window.location.href = `${
                process.env.VUE_APP_SERVER
              }/sso/oauth/logout?response_type=code&state=qm-ui&client_id=${
                process.env.VUE_APP_SSO_CLIENT_ID || "qm-ui"
              }&redirect_uri=${process.env.VUE_APP_SSO_REDIRECT_URL}`;
        } else {
          window.vue.$router.push('/login');
        }
      },
      oauthLogin: () => {
        window.vue.$router.push('/oauthLogin');
      },
      register: () => {
        window.vue.$router.push('/register');
      },
      to: (url) => {
        window.vue.$router.push(url);
      },
      back: () => {
        window.vue.$router.go(-1);
      },
    };
  }
}

export default Framework;
